<?php
use yii\helpers\Url;

$web = Url::base();
$url = Yii::$app->request->scriptUrl;
?>
<input type="hidden" id="inputPersonId" value="<?= $item['id'] ?>">
<div class="modal-body">
    <div class="form-horizontal">
        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">机构:</label>
            <div class="col-lg-9">
                <input type="text" class="form-control" id="inputPersonInstitution" disabled="false"
                       value="<?= $item['institution_name'] ?>"/>
                <!--<select class="form-control" id="inputPersonInstitution" disabled="false">
                    <option value="0">----系统----</option>
                    <?php
                /*                    foreach ($institutions as $institution) {
                                        if ($institution['code'] == $item['institution_code']) {
                                            */ ?>
                            <option value=" <? /*= $institution['code'] */ ?>" selected><? /*= $institution['name'] */ ?></option>
                            <?php
                /*                        } else {
                                            */ ?>
                            <option value="<? /*= $institution['code'] */ ?>"><? /*= $institution['name'] */ ?></option>
                            <?php
                /*                        }
                                    }
                                    */ ?>
                </select>-->
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">姓名:</label>
            <div class="col-lg-9">
                <input type="text" class="form-control" id="inputPersonName" value="<?= $item['name'] ?>"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">账号:</label>
            <div class="col-lg-9">
                <input type="text" class="form-control" id="inputPersonAccount" disabled="false"
                       value="<?= $item['account'] ?>"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">密码:</label>
            <div class="col-lg-9">
                <input type="password" class="form-control" id="inputPassword" disabled
                       value="<?= $item['password'] ?>"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">手机号码:</label>
            <div class="col-lg-9">
                <input type="tel" class="form-control" id="inputPersonPhone" value="<?= $item['phone'] ?>"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">是否启用:</label>
            <div class="col-lg-9">
                <select class="form-control" id="inputPersonIsEnabled" disabled="false">
                    <?php
                    if ($item['is_enabled'] == 1) {
                        ?>
                        <option value="1" selected>启用</option>
                        <option value="0">禁用</option>
                        <?php
                    } else {
                        ?>
                        <option value="1">启用</option>
                        <option value="0" selected>禁用</option>
                        <?php
                    }
                    ?>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label col-lg-3">备注:</label>
            <div class="col-lg-9">
                <textarea rows="4" class="form-control" id="inputPersonRemark"><?= $item['remark'] ?></textarea>
            </div>
        </div>

        <!--<div class="form-group" style="display: none">
            <div class="panel">
                <div class="panel-heading">
                    角色配置
                </div>
                <div class="panel-body">
                    <?php
        /*                    foreach ($roleList as $role) {
                                $isChecked = '';
                                if (in_array($role['id'], $item['role_list'])) {
                                    $isChecked = 'checked';
                                }
                                */ ?>
                        <div class="square-blue form-inline icheck col-lg-4">
                            <div class="checkbox popovers" data-trigger="hover" data-placement="top" data-original-title="<? /*= $role['name'] */ ?>" data-content="<? /*= $role['description'] */ ?>">
                                <input type="checkbox" <? /*= $isChecked */ ?> name="role" value="<? /*= $role['id'] */ ?>">
                                <label><? /*= $role['name'] */ ?> </label>
                            </div>
                        </div>
                        <?php
        /*                    }
                            */ ?>
                </div>
            </div>
        </div>-->
    </div>
</div>

<div class="modal-footer">
    <button class="btn btn-default" data-dismiss="modal">关闭</button>
    <?php if (\app\models\Manager::getCurrentManager()['id'] != '0') {
        ?>
        <button class="btn btn-primary" id="btnModifyOk">保存修改</button>
        <?php
    }
    ?>

</div>

<script type="application/javascript">
    $(function () {
        $('.square-blue input').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' // optional
        });

        $('#btnModifyOk').click(function () {
            loading.show();
            var data = {};
            data.id = $('#inputPersonId').val();
            //data.institution_code = $('#inputPersonInstitution').val()._trim();
            data.name = $('#inputPersonName').val();
            //data.account = $('#inputPersonAccount').val();
            data.phone = $('#inputPersonPhone').val();
            //data.is_enabled = $('#inputPersonIsEnabled').val();
            data.remark = $('#inputPersonRemark').val();
            requestJson('<?= $url ?>/system/modify-manager-info-handler', data, true, function (responseData) {
                loading.hide();
                if (responseData.status == 0) {
                    window.location.reload();
                } else {
                    alert(responseData.message);
                }
            });
        });
    });
</script>
